﻿#ifndef CONNECTIONDIALOG_H
#define CONNECTIONDIALOG_H

#include <QDialog>
#include <QRadioButton>
#include <QLineEdit>
#include <QVBoxLayout>
#include <QPushButton>
#include <QLabel>
#include <QButtonGroup>
#include <QFormLayout>

class ConnectionDialog : public QDialog
{
    Q_OBJECT

public:
    explicit ConnectionDialog(QWidget *parent = nullptr);
    QString getLocalDbName() const;
    QString getHost() const;
    QString getPort() const;
    QString getRemoteDbName() const;
    QString getUsername() const;
    QString getPassword() const;
    QRadioButton *localConnectionRadioButton;
    QRadioButton *remoteConnectionRadioButton;

private slots:
    void onConnectionTypeChanged();
    void onFieldsChanged(); // 新增槽函数
signals:
    void connectionStatusChanged(bool isFilled);
private:
    void setupUi();
    void setupConnections();

    QLineEdit *localDbNameEdit;
    QLineEdit *hostEdit;
    QLineEdit *portEdit;
    QLineEdit *remoteDbNameEdit;
    QLineEdit *usernameEdit;
    QLineEdit *passwordEdit;
    QLabel *localLabel;
    QLabel *remoteLabel1;
    QLabel *remoteLabel2;
    QLabel *remoteLabel3;
    QLabel *remoteLabel4;
    QLabel *remoteLabel5;
    QVBoxLayout *mainLayout;
    QVBoxLayout *remoteLayout;
    QVBoxLayout *localLayout;
    QPushButton *connectButton;
    QPushButton *cancelButton;
};

#endif // CONNECTIONDIALOG_H
